<?php
declare (strict_types=1);

namespace app\common\dao\activity\lottery;

use app\common\model\activity\lottery\LuckPrize;
use app\common\dao\BaseDao;


/**
 *
 * Class LuckPrizeDao
 * @package app\common\dao\activity\lottery
 */
class LuckPrizeDao extends BaseDao
{
    /**
     * @return string
     * @day: 2024/1/28
     */
    protected function getModel(): string
    {
        return LuckPrize::class;
    }

    /**
     * @param int $lottery_id
     * @param string $field
     * @return array
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     * @author: fupeng
     * 获取某个活动所有奖品
     */
    public function getPrizeList(int $lottery_id, string $field = '*')
    {
        $where = ['is_del' => 0, 'status' => 1,'lottery_id' => $lottery_id];
        return LuckPrize::getDB()->where($where)
            ->field($field)->order('sort desc,id desc')->select()
            ->toArray();
    }

    public function insert(array $data)
    {
        return LuckPrize::getDB()->insert($data,true);
    }
}
